home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3597 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.2 KB

  1. Path: oxy.rust.net!usenet
  2. From: ebennett@rust.net
  3. Newsgroups: comp.os.ms-windows.programmer.tools.mfc,comp.os.ms-windows.apps.compatibility.win95,comp.lang.c++
  4. Subject: Re: HELP !!! Memory - Allocation
  5. Date: Thu, 25 Jan 1996 04:01:25 GMT
  6. Organization: Rust Net - High Speed Internet in Detroit  810-642-2276
  7. Message-ID: <4e6kof$ela@oxy.rust.net>
  8. References: <NEWTNews.751.822443462.Postmaster@Jerusalem.netvision.net.il>
  9. NNTP-Posting-Host: liv-18.rust.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. iti@Jerusalem.netvision.net.il wrote:
  13.  
  14. >I am using Visual C++ to write a Windows Application - and I am having
  15. >a memory problem. I want to dynamically allocate "nTemp" bytes of memory
  16. >to read in a char string, or the most memory available up to "nTemp" 
  17. >bytes.  
  18.  
  19. >My questions being:
  20. >    1. How can I most efficiantly do this?
  21. >    2. Should I use 
  22. >            -> pChar = (char*) malloc(nTemp); Or
  23. >            -> pChar = new char[nTemp];
  24.  
  25. Personal Opinion:  If you are using C++, use C++.  (i.e., go with new
  26. instead of malloc).  The only technical reason for this is to make
  27. sure object constructors are called when allocating an array of
  28. objects.  In this case it really does not matter, but I would avoid
  29. using malloc in C++ code.
  30.  
  31. Earl Bennett
  32.  
  33.